package com.ss.android.article.base.utils;

import org.json.JSONException;
import org.json.JSONObject;

public final class JSONObjectWrapper {
    public JSONObject jsonObject;

    public JSONObjectWrapper() {
        this.jsonObject = new JSONObject();
    }

    public final JSONObjectWrapper put(String key, int value) {
        try {
            this.jsonObject.put(key, value);
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
            this.jsonObject.remove(key);
        }
        return this;
    }

    public final JSONObjectWrapper put(String key, Object value) {
        try {
            this.jsonObject.put(key, value);
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
            this.jsonObject.remove(key);
        }

        return this;
    }

    public final JSONObjectWrapper put(String key, long value) {
        try {
            this.jsonObject.put(key, value);
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
            this.jsonObject.remove(key);
        }

        return this;
    }

    public final JSONObjectWrapper put(String key, boolean value) {
        try {
            this.jsonObject.put(key, value);
        } catch (JSONException jsonException) {
            jsonException.printStackTrace();
            this.jsonObject.remove(key);
        }

        return this;
    }
}

